<template>
		<view class="goods_list">
			<goods-list @goodsItemClick="goGoodsDetail" :goods="goods"></goods-list>
			<view class="isover" v-if="flag">--我是有底线的--</view>
		</view>
</template>

<script>
	import goodsList from '../../components/goods-list/goods-list.vue'
	export default {
		components:{"goods-list":goodsList},
		data() {
			return {
				pageindex:1,
				goods:[],
				flag:false
			}
		},
		methods: {
			//获取商品列表
			async getGoodsList(){
				const res=await this.$myRuquest({
					url:'/api/getgoods?pageindex='+this.pageindex
				})
				// this.goods=res.data.message
				this.goods=[...this.goods,...res.data.message]
				// callBack && callBack()
			},
			goGoodsDetail(id){
				console.log("点击了")
				uni.navigateTo({
					url:'/pages/goods-detail/goods-detail?id='+id
				})
			},
			onReachBottom(){
				//下拉加载更多
				if(this.goods.length<this.pageindex*10)
				return this.flag=true
				this.pageindex++
				this.getGoodsList()
			},
			onPullDownRefresh(){
				this.pageindex=1
			}
		},
		onLoad() {
			this.getGoodsList()
		},
	}
</script>

<style lang="scss">
.goods_list{
		background: #eee;
		}
	.isover{
		width: 100%;
		height: 50px;
		text-align: center;
		background: #eee;
		font-size: 28rpx;
	}

</style>
